<?
include_once("db.php");
include_once("design.php");

$sql = "SELECT *, DATE_FORMAT(Startdato, '%d.%m.%Y') AS Startdatostr, DATE_FORMAT(Sluttdato, '%d.%m.%Y') AS Sluttdatostr FROM Laiv WHERE Startdato >= NOW() AND Offentlig=1 ORDER BY Startdato DESC";
$planlagte = mysql_query($sql) or die("Kunne ikke hente arrangementer");

$sql = "SELECT *, DATE_FORMAT(Startdato, '%d.%m.%Y') AS Startdatostr, DATE_FORMAT(Sluttdato, '%d.%m.%Y') AS Sluttdatostr, YEAR(Startdato) AS Aar FROM Laiv WHERE Startdato < NOW() AND Offentlig=1 ORDER BY Startdato DESC";
$avholdte = mysql_query($sql) or die("Kunne ikke hente arrangementer");

$sidetittel="Arrangementer";
include("top.php");

printarr("Planlagte arrangementer", $planlagte);
printarr("Avholdte stand-alone arrangementer", $avholdte, true);

headline("Andre prosjekter");

$txt="<strong><a href=\"../den12profeti/index.php\">Den Tolvte Profeti</a></strong> (2004)\n";
$txt.="<strong>Grevinne von Hertzenkranz veldedighetsball (Gathering)</strong> (2004)\n";
$txt.="<strong><a href=\"../2092/index.htm\">2092: En ny soloppgang (Ny-Kirkevik II)</a></strong> (2003)\n";
$txt.="<strong><a href=\"../ikaria2/index.htm\">Kong Ikanors Testamente</a></strong> (2002)\n";
$txt.="<strong><a href=\"../nykirkevik/index.htm\">Ny-Kirkevik</a></strong> (2001)\n";
$txt.="<strong><a href=\"../taina/index.htm\">Tainas Idoler</a></strong> (2000)\n";

text($txt);


include("bottom.php");

function printarr ($tittel, $data, $printaar=false) {

	headline($tittel);

	if (mysql_num_rows($data)) {
		$body = "<table>\n";
		while ($arr=mysql_fetch_assoc($data)) {
			$tittel=$arr['Tittel'];
			$aar = $arr['Aar'];
			$datostr = $arr['Startdatostr']." - ".$arr['Sluttdatostr'];
			$link = "arrindex.php?laivID=".$arr['ID'];
			
			$body .= "<tr>\n\t<td><strong><a href=\"$link\">$tittel</a></strong>\n";
			if ($printaar)
				$body .= " ($aar)";
			
			$body .= "</td>\n</tr>\n";
		}

		$body .= "</table>\n";
	} else {
		$body = "Ingen arrangementer i denne kategorien...";
	}

	text($body, false);
}
?>
